<?php
if(!defined('ADMIN')){
	exit('Access Denied');
}

if($_POST['sub']!=''){

    $id=empty($_POST['id'])?0:(int)$_POST['id'];
	unset($_POST['id']);
	unset($_POST['sub']);
	$data=array('title'=>$_POST['title'],"linktype"=>intval($_POST["linktype"]),"passed"=>intval($_POST["passed"]),
    "logo"=>trim($_POST["attachment_fileName"]),
    "url"=>trim($_POST["url"]),
    "addtime"=>time(),
    "uid"=>$_SESSION['EZ_Admin']['id'],    
    "username"=>$_SESSION['EZ_Admin']['name']
    );
    if(trim($_POST['title'])==""){
        jumpajax('300','网站名称不能为空','');
    }

   
 	if($id==0){
	    $id=$ezhand->insert("link",$data);
		jumpajax('200','保存成功','','closeCurrent');
	}
	else{
	    $ezhand->update("link",$data,'id="'.$id.'"');
		jumpajax('200','修改成功','','closeCurrent');
	}
}
else{
	$id=empty($_GET['id'])?0:(int)$_GET['id'];
    
    if($id==0){
	    $row=array();
	}
	else{
	    $row=$ezhand->select("link",'*','id="'.$id.'"');
	}
}
?>